'use strict';
const express = require('express');
const router = express.Router();
const {createLedgerOrg1,org1Repo2Transfer} = require('org1App.js');
const {createLedgerOrg3,org3Repo2Transfer} = require('org3App.js');
const {checkOrg1Transaction,checkOrg3Transaction,org1Transfer2School,org3Transfer2School,org1School2Buyer,org3School2Buyer} = require('org2App.js');

router.get('/f1', async function (req, res, next) {
  	var str = await createLedgerOrg1(req.params.l);
  	res.send(str);
})

router.get('/f2', async function (req, res, next) {
	var str = await org1Repo2Transfer(req.params.l);
	res.send(str);
})

router.get('/f3', async function (req, res, next) {
	var str = await createLedgerOrg3(req.params.l);
	res.send(str);
})

router.get('/f4', async function (req, res, next) {
	var str = await org3Repo2Transfer(req.params.l);
	res.send(str);
})

router.get('/f5', async function (req, res, next) {
	var str = await checkOrg1Transaction(req.params.l);
	res.send(str);
})

router.get('/f6', async function (req, res, next) {
	var str = await checkOrg3Transaction(req.params.l);
	res.send(str);
})

router.get('/f7', async function (req, res, next) {
	var str = await org1Transfer2School(req.params.l);
	res.send(str);
})

router.get('/f8', async function (req, res, next) {
	var str = await org3Transfer2School(req.params.l);
	res.send(str);
})

router.get('/f9', async function (req, res, next) {
	var str = await org1School2Buyer(req.params.l);
	res.send(str);
})

router.get('/f10', async function (req, res, next) {
	var str = await org3School2Buyer(req.params.l);
	res.send(str);
})

module.exports = router;

/*【使用方法】
public static void main(String[] args) {
  //调用fabricAPI中createLedger函数
  HttpRequest.sendGet("http://127.0.0.1:3000/call_fabric/createLedger", "l=xxx");

  HttpRequest.sendGet("http://127.0.0.1:3000/call_fabric/repoToTransfer", "l=xxx");

  HttpRequest.sendGet("http://127.0.0.1:3000/call_fabric/readAssets", "l=xxx");

  HttpRequest.sendGet("http://127.0.0.1:3000/call_fabric/transferToDestination", "l=xxx");

  HttpRequest.sendGet("http://127.0.0.1:3000/call_fabric/destinationToBuyer", "l=xxx");
  
}
*/